﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using RuntimeTypeGenerator;
using Newtonsoft.Json.Schema;

namespace RuntimeTypeGeneratorTest
{
    [TestClass]
    public class JsonSchemaBuilderTest
    {
        [TestMethod]
        public void TestMethod1()
        {
            var generated = new GeneratedAssembly("Test");

            var jsonSchema = JsonSchema.Parse(Properties.Resources.Person_JSONSchema);
            var type = new JsonSchemaTypeBuilder(jsonSchema).BuildTo(generated);

            Assert.AreEqual("Test.Person", type.FullName, "Wrong generated type name");
            Assert.AreEqual(3, type.GetFields().Length, "Wrong generated fields number");
            Assert.AreEqual("Person[]", type.GetFields()[2].FieldType.Name, "Wrong generated array field type");
        }
    }
}
